<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/common/includes.jsp" %>
<%@ include file="/WEB-INF/view/inc.jsp" %>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<style>
    .panel-body {
        border-bottom-width: 0px;
        border-left-width: 0px;
    }

    .layout-expand .panel-header {
        border-width: 0px;
    }

</style>
<body class="easyui-layout" data-options="fit:true,border:false">
<!-- 搜索框 -->
<div data-options="region:'north',title:'查询条件',border:false" style="height:80px; overflow: hidden;border: 0px;">
    <form id="searchForm">
        <div class="fitem fl">
            <label>文章标题:</label>
            <input name="title" class="easyui-textbox">
        </div>
        <div class="fitem searchItem fr">
            <a class="easyui-linkbutton" iconCls="icon-search" onclick="sy_searchFun()">搜索</a>
            <a class="easyui-linkbutton" iconCls="icon-reload" onclick="sy_resetFun()">重置</a>
        </div>
    </form>
</div>
<div data-options="region:'center',border:false">
    <table id="grid" class="easyui-datagrid" fit="true"
           data-options="url: '<%=contextPath%>/article/list',method: 'post',pagination: true,rownumbers:true,idField: 'id', fitColumns:true,singleSelect:true,striped:true,sortName:'createTime',sortOrder:'desc',toolbar: '#toolbar'">
        <thead>
        <tr>
            <th data-options="field:'title'" width="100" sortable="true">文章标题</th>
            <th data-options="field:'abstractn'" width="100" sortable="true">内容简介</th>
            <th data-options="field:'details'" width="100" sortable="true">详情内容</th>
            <th data-options="field:'img'" width="100" sortable="true">图片</th>
        </tr>
        </thead>
    </table>
</div>
<!-- 按钮-->
<div id="toolbar" style="display: none;">
    <t:button action="article_add" iconCls="icon-add" buttonName="新增" onclick="sy_addFun('/article/toSaveAndUpdate','添加article信息')"/>
    <t:button action="article_edit" iconCls="icon-edit" buttonName="编辑" onclick="sy_editFun('/article/toSaveAndUpdate','修改article信息')"/>
    <t:button action="article_remove" iconCls="icon-remove" buttonName="删除" onclick="sy_removeGridFun_tip('/article/delete')"/>
</div>
</body>
<script>
    var toadd_article = function(url,title){
        debugger
        var dialog;
        dialog = $("<div><iframe></iframe></div>").dialog({
            title: title,
            width: 600,
            height: 500,
            closed: false,
            cache: false,
            href: url,
            modal: true,
            buttons:[{
                text:'保存',
                handler:function(){
                    add_article();
                }

            },{
                text:'关闭',
                handler:function(){
                    dialog.dialog('destroy');
              }
            }]

        });

    }

    var add_article = function(){
        debugger
        var data = sy.serializeObject($("#fm"));
        $.ajaxFileUpload({
            url:"/article/saveAndUpdate",
            data:"data",
            fileElementId:'fileToUpload',
            type:"post",
            dataType:"text",
            success:function(j){
                alert(j);
            }
        })

    }

   /* var uploadImg = function() {
        debugger;
        $.ajaxFileUpload({
            url: "/article/uploadImg",
            fileElementId: "fileToUpload",
            type: "post",
            success: function (result) {
                debugger
                if (result == "0") {
                    $.messager.alert("错误", "请选择上传的图片");
                } else if (result == "1") {
                    $.messager.alert("错误", "有单个文件超过5M");
                } else {

                    var imgArray = result.split(",");
                    $.each(imgArray, function (i, item) {
                                var id = item.substring(0, 32);
                                var div = $("<div class='img_Div_hidden' id=" + id + "  style='float: left;margin-left: 3px;margin-bottom: 3px; '/>");
                                var del_but = $("<div class='img_del' onclick='delImg(\"" + id + "\")' />");
                                var img_but = $("<img src='/jslib/common/images/button/close.png'  style='width: 10px;float: right;'>");
                                var img_add = $(" <img class='img-square' src='/cookbook/getImg?imgName=" + item + " 'style='width: 100px;'>");
                                var input = $("<input name='img' type='hidden' value=" + item + ">");
                                del_but.append(img_but);
                                div.append(del_but);
                                div.append(img_add);
                                div.append(input);
                                $("#fm").append(div);
                            }
                    )
                }
            }
        })
    }
    var delImg = function(id){
        $("#"+id).remove();
    }
*/
</script>
</html>



